﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ajaxUpdate : GH.Web.BasePage.PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //更新区分
            string strUpdateFlg = Request["UpdateFlg"].ToString();
            //处理画面区分
            string strFormFlg = Request["FormFlg"].ToString();
            switch (strFormFlg)
            {
                //用户
                case "USER":
                    GH.BLL.User bllUser = new GH.BLL.User();
                    GH.Model.用户信息 mdUser = new GH.Model.用户信息();
                    if (strUpdateFlg == "Update")
                    {
                        mdUser.ID = int.Parse(Request["ID"].ToString());
                        mdUser.用户ID = Request["UserID"].ToString();
                        mdUser.单位 = int.Parse(Request["Uion"].ToString());
                        mdUser.部门 = int.Parse(Request["Department"].ToString());
                        mdUser.角色ID = int.Parse(Request["Role"].ToString());
                        mdUser.登陆密码 = Request["Password"].ToString();
                        mdUser.启用状态 = Request["UseState"].ToString();
                        bllUser.Update(mdUser);
                    }
                    else if (strUpdateFlg == "Add")
                    {
                        mdUser.用户ID = Request["UserID"].ToString();
                        mdUser.单位 = int.Parse(Request["Uion"].ToString());
                        mdUser.部门 = int.Parse(Request["Department"].ToString());
                        mdUser.角色ID = int.Parse(Request["Role"].ToString());
                        mdUser.登陆密码 = Request["Password"].ToString();
                        mdUser.启用状态 = Request["UseState"].ToString();
                        bllUser.Add(mdUser);
                    }
                    else
                    {
                        bllUser.Delete(int.Parse(Request["ID"].ToString()));
                    }
                    break;
                //部门管理
                case "DepartMent":
                    GH.BLL.DepartMent bllDepartment = new GH.BLL.DepartMent();
                    GH.Model.部门信息 mdlDepartMentInfo = new GH.Model.部门信息();
                    if (strUpdateFlg == "Update")
                    {
                        mdlDepartMentInfo.ID = int.Parse(Request["ID"].ToString());
                        mdlDepartMentInfo.单位ID = int.Parse(Request["UnionID"].ToString());
                        mdlDepartMentInfo.部门代码 = Request["DepartMentID"].ToString();
                        mdlDepartMentInfo.部门名称 = Request["DepartMentName"].ToString();
                        mdlDepartMentInfo.部门负责人 = Request["Leader"].ToString();
                        bllDepartment.Update(mdlDepartMentInfo);
                    }
                    else if (strUpdateFlg == "Add")
                    {
                        mdlDepartMentInfo.单位ID = int.Parse(Request["UnionID"].ToString());
                        mdlDepartMentInfo.部门代码 = Request["DepartMentID"].ToString();
                        mdlDepartMentInfo.部门名称 = Request["DepartMentName"].ToString();
                        mdlDepartMentInfo.部门负责人 = Request["Leader"].ToString();
                        bllDepartment.Add(mdlDepartMentInfo);
                    }
                    else
                    {
                        bllDepartment.Delete(int.Parse(Request["ID"].ToString()));
                    }
                    break;
                //班组管理 WorkGroup
                case "WorkGroup":
                    GH.BLL.Group bllGroup = new GH.BLL.Group();
                    GH.Model.班组信息 mdGroup = new GH.Model.班组信息();
                    if (strUpdateFlg == "Update")
                    {
                        mdGroup.ID = int.Parse(Request["ID"].ToString());
                        mdGroup.单位ID = int.Parse(Request["UnionID"].ToString());
                        mdGroup.班组代码 = Request["WorkGroupID"].ToString();
                        mdGroup.班组名称 = Request["WorkGroupName"].ToString();
                        mdGroup.班组组长 = Request["Leader"].ToString();
                        bllGroup.Update(mdGroup);
                    }
                    else if (strUpdateFlg == "Add")
                    {
                        mdGroup.单位ID = int.Parse(Request["UnionID"].ToString());
                        mdGroup.班组代码 = Request["WorkGroupID"].ToString();
                        mdGroup.班组名称 = Request["WorkGroupName"].ToString();
                        mdGroup.班组组长 = Request["Leader"].ToString();
                        bllGroup.Add(mdGroup);
                    }
                    else
                    {
                        bllGroup.Delete(int.Parse(Request["ID"].ToString()));
                    }
                    break;
                //角色管理  Role
                case "Role":
                    GH.BLL.Role bllRole = new GH.BLL.Role();
                    GH.Model.角色信息 mdRole = new GH.Model.角色信息();
                    if (strUpdateFlg == "Update")
                    {
                        mdRole.角色ID = int.Parse(Request["RoleId"].ToString());
                        mdRole.角色名称 = Request["RoleName"].ToString();
                        mdRole.备注 = Request["Remark"].ToString();
                        bllRole.Update(mdRole);
                    }
                    else if (strUpdateFlg == "Add")
                    {
                        mdRole.角色名称 = Request["RoleName"].ToString();
                        mdRole.备注 = Request["Remark"].ToString();
                        bllRole.Add(mdRole);
                    }
                    else
                    {
                        bllRole.Delete(int.Parse(Request["RoleId"].ToString()));
                    }
                    break;
                //会员管理  VipMember
                case "VipMember":
                    GH.BLL.VipMember VipBll = new GH.BLL.VipMember();
                    if (strUpdateFlg == "Delete")
                    {
                        int id = Convert.ToInt32(Request["Id"]);
                        VipBll.Delete(id);
                    }
                    break;
                //家庭管理  
                case "Family":
                    GH.BLL.VipMemberFamily FamilyBLL = new GH.BLL.VipMemberFamily();
                    if (strUpdateFlg == "Delete")
                    {
                        int id = Convert.ToInt32(Request["Id"]);
                        string strIndex = Request["Index"].ToString();
                        FamilyBLL.Delete(id, int.Parse(strIndex));
                    }
                    else
                        if (strUpdateFlg == "Add")
                        {

                            string VipID = Request["VIPID"].ToString();
                            string Name = Request["Name"].ToString();
                            string Relation = Request["Relation"].ToString();
                            string Unit = Request["Unit"].ToString();
                            DateTime? Birthday;
                            if (Request["Birthday"].ToString() == "")
                            {
                                Birthday = null;
                            }
                            else
                            {
                                Birthday = Convert.ToDateTime(Request["Birthday"]);
                            }
                            string Pay = Request["Pay"].ToString();
                            string Marital = Request["Marital"].ToString();
                            string Support = Request["Support"].ToString();
                            string Project = Request["Project"].ToString();
                            string Address = Request["Address"].ToString();

                            GH.Model.会员家属信息 FamilyModel = new GH.Model.会员家属信息();

                            FamilyModel.姓名 = Name;
                            FamilyModel.序号 = Convert.ToInt32(VipID); ;
                            FamilyModel.出生年月日 = Birthday;
                            FamilyModel.与本人关系 = Relation;
                            FamilyModel.工作单位 = Unit;
                            FamilyModel.月收入 = (Pay == "" ? 0 : Convert.ToInt32(Pay));
                            FamilyModel.婚姻状况 = Marital;
                            FamilyModel.供养关系 = Support;
                            FamilyModel.领取项目 = Project;
                            FamilyModel.现住址 = Address;
                            FamilyBLL.Add(FamilyModel);

                        }
                        else if (strUpdateFlg == "Update")
                        {
                            string ID = Request["ID"].ToString();
                            string Name = Request["Name"].ToString();
                            string Relation = Request["Relation"].ToString();
                            string Unit = Request["Unit"].ToString();
                            DateTime? Birthday;
                            if (Request["Birthday"].ToString() == "")
                            {
                                Birthday = null;
                            }
                            else
                            {
                                Birthday = Convert.ToDateTime(Request["Birthday"]);
                            }
                            string Pay = Request["Pay"].ToString();
                            string Marital = Request["Marital"].ToString();
                            string Support = Request["Support"].ToString();
                            string Project = Request["Project"].ToString();
                            string Address = Request["Address"].ToString();

                            GH.Model.会员家属信息 FamilyModel = new GH.Model.会员家属信息();
                            FamilyModel = FamilyBLL.GetModel(int.Parse(ID));
                            FamilyModel.姓名 = Name;
                            FamilyModel.出生年月日 = Birthday;
                            FamilyModel.与本人关系 = Relation;
                            FamilyModel.工作单位 = Unit;
                            FamilyModel.月收入 = (Pay == "" ? 0 : Convert.ToInt32(Pay));
                            FamilyModel.婚姻状况 = Marital;
                            FamilyModel.供养关系 = Support;
                            FamilyModel.领取项目 = Project;
                            FamilyModel.现住址 = Address;
                            FamilyBLL.Update(FamilyModel);

                        }
                    break;
                //权限设置管理  Role
                case "RoleSet":
                    if (strUpdateFlg == "UpdateRole")
                    {
                        string RoleID = Request["RoleID"].ToString().Trim();
                        string[] arrActionId = Request["Actions"].ToString().Split('|');

                        GH.BLL.Rights RoleBLL = new GH.BLL.Rights();

                        RoleBLL.DeleteByRoleID(Convert.ToInt32(RoleID));

                        foreach (var item in arrActionId)
                        {
                            if (item != "")
                            {
                                GH.Model.角色权限表 RoleActionModel = new GH.Model.角色权限表();

                                RoleActionModel.角色ID = Convert.ToInt32(RoleID);
                                RoleActionModel.权限ID = Convert.ToInt32(item);
                                RoleBLL.Add(RoleActionModel);
                            }
                        }

                    }
                    else if (strUpdateFlg == "SetRoleGroup")
                    {
                        GH.BLL.User UserBLL = new GH.BLL.User();
                        string RoleID = Request["RoleID"].ToString().Trim();
                        string[] arrUserId = Request["UserIDs"].ToString().Split('|');
                        foreach (var item in arrUserId)
                        {
                            if (item != "")
                            {
                                int userID = Convert.ToInt32(item);
                                GH.Model.用户信息 UserModel = UserBLL.GetModel(userID);
                                UserModel.角色ID = Convert.ToInt32(RoleID);
                                UserBLL.Update(UserModel);
                            }
                        }

                    }
                    break;
                //工会组织机构统计表 
                case "OrganizationSumirise":
                    System.Collections.Generic.List<GH.Model.工会组织机构统计表> listModel = new List<GH.Model.工会组织机构统计表>();
                    string[] strUnionArray = Request["Union"].ToString().Split(',');
                    string[] strTermArray = Request["Term"].ToString().Split(',');
                    string[] strRealChiareManArray = Request["RealChiareMan"].ToString().Split(',');
                    string[] strChiareManArray = Request["ChiareMan"].ToString().Split(',');
                    string[] strMemberArray = Request["Member"].ToString().Split(',');
                    string[] strWorkContentArray = Request["WorkContent"].ToString().Split(',');
                    string[] strRemarkArray = Request["Remark"].ToString().Split(',');
                    string[] strNo = Request["No"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < strUnionArray.Length - 1; intIndex++)
                    {
                        GH.Model.工会组织机构统计表 modeAdd = new GH.Model.工会组织机构统计表();
                        modeAdd.No = int.Parse(strNo[intIndex].ToString());
                        modeAdd.单位 = int.Parse(strUnionArray[intIndex].ToString());
                        modeAdd.届数 = strTermArray[intIndex].ToString();
                        modeAdd.主席 = strRealChiareManArray[intIndex].ToString();
                        modeAdd.副主席 = strChiareManArray[intIndex].ToString();
                        modeAdd.委员姓名 = strMemberArray[intIndex].ToString();
                        modeAdd.委员分工 = strWorkContentArray[intIndex].ToString();
                        modeAdd.备注 = strRemarkArray[intIndex].ToString();
                        listModel.Add(modeAdd);
                    }
                    GH.BLL.ReportOrganization bllReportOrganization = new GH.BLL.ReportOrganization();
                    bllReportOrganization.UpdateOrganizationList(listModel, int.Parse(this.Session["UnionSelect"].ToString()));
                    break;
                //互助员工
                case "MutualMemberSumirise":
                    System.Collections.Generic.List<GH.Model.互助员工统计表> huzhulistModel = new List<GH.Model.互助员工统计表>();
                    string[] huzhuUnion = Request["Union"].ToString().Split(','); ;
                    string[] huzhuVipName = Request["vipName"].ToString().Split(',');
                    string[] huzhuSex = Request["sex"].ToString().Split(',');
                    string[] huzhuInsuretime = Request["insuretime"].ToString().Split(',');
                    string[] huzhuInsureamount = Request["insureamount"].ToString().Split(',');
                    string[] huzhuGranttime1 = Request["granttime1"].ToString().Split(',');
                    string[] huzhuGrantamount1 = Request["grantamount1"].ToString().Split(',');
                    string[] huzhuGranttime2 = Request["granttime2"].ToString().Split(',');
                    string[] huzhuGrantamount2 = Request["grantamount2"].ToString().Split(',');
                    string[] huzhuGranttime3 = Request["granttime3"].ToString().Split(',');
                    string[] huzhuGrantamount3 = Request["grantamount3"].ToString().Split(',');
                    string[] huzhuGranttime4 = Request["granttime4"].ToString().Split(',');
                    string[] huzhuGrantamount4 = Request["grantamount4"].ToString().Split(',');
                    string[] huzhuGranttime5 = Request["granttime5"].ToString().Split(',');
                    string[] huzhuGrantamount5 = Request["grantamount5"].ToString().Split(',');
                    string[] huzhuremark = Request["Remark"].ToString().Split(',');
                    string[] huzhuNos = Request["nos"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < huzhuSex.Length - 1; intIndex++)
                    {
                        GH.Model.互助员工统计表 modeAdd = new GH.Model.互助员工统计表();
                        modeAdd.单位 = int.Parse(huzhuUnion[intIndex].ToString());
                        modeAdd.姓名 = huzhuVipName[intIndex].ToString();
                        modeAdd.性别 = huzhuSex[intIndex].ToString();
                        modeAdd.投保时间 = Convert.ToDateTime(huzhuInsuretime[intIndex]);
                        modeAdd.投保金额 = Convert.ToInt32(huzhuInsureamount[intIndex]);

                        try
                        {

                            modeAdd.补助时间1 = Convert.ToDateTime(huzhuGranttime1[intIndex]);
                            modeAdd.金额1 = Convert.ToInt32(huzhuGrantamount1[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.补助时间1 = null;
                            modeAdd.金额1 = null;
                        }


                        try
                        {

                            modeAdd.补助时间2 = Convert.ToDateTime(huzhuGranttime2[intIndex]);
                            modeAdd.金额2 = Convert.ToInt32(huzhuGrantamount2[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.补助时间2 = null;
                            modeAdd.金额2 = null;
                        }


                        try
                        {

                            modeAdd.补助时间3 = Convert.ToDateTime(huzhuGranttime3[intIndex]);
                            modeAdd.金额3 = Convert.ToInt32(huzhuGrantamount3[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.补助时间3 = null;
                            modeAdd.金额3 = null;
                        }


                        try
                        {

                            modeAdd.补助时间4 = Convert.ToDateTime(huzhuGranttime4[intIndex]);
                            modeAdd.金额4 = Convert.ToInt32(huzhuGrantamount4[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.补助时间4 = null;
                            modeAdd.金额4 = null;
                        }

                        try
                        {

                            modeAdd.补助时间5 = Convert.ToDateTime(huzhuGranttime5[intIndex]);
                            modeAdd.金额5 = Convert.ToInt32(huzhuGrantamount5[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.补助时间5 = null;
                            modeAdd.金额5 = null;
                        }

                        modeAdd.备注 = huzhuremark[intIndex].ToString();
                        modeAdd.No = Convert.ToInt32(huzhuNos[intIndex]);
                        huzhulistModel.Add(modeAdd);
                    }
                    GH.BLL.MutualMember bllMutualMember = new GH.BLL.MutualMember();
                    bllMutualMember.UpdateList(huzhulistModel);
                    break;

                //疗养情况
                case "RecuperateCondationSumirise":
                    System.Collections.Generic.List<GH.Model.疗养情况统计表> liaoyangqklistModel = new List<GH.Model.疗养情况统计表>();
                    string[] liaoyangqkUnion = Request["Union"].ToString().Split(','); ;
                    string[] nos = Request["no"].ToString().Split(',');
                    string[] liaoyangqkVipName = Request["vipName"].ToString().Split(',');
                    string liaoyangqkYear = Request["theYear"].ToString();
                    string[] liaoyangqkworkbegintime = Request["workbegintime"].ToString().Split(',');
                    string[] liaoyangqkenjoystandard = Request["enjoystandard"].ToString().Split(',');
                    string[] liaoyangqkrecuperationtime = Request["recuperationtime"].ToString().Split(',');
                    string[] liaoyangqkremark = Request["Remark"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < liaoyangqkVipName.Length - 1; intIndex++)
                    {

                        GH.Model.疗养情况统计表 modeAdd = new GH.Model.疗养情况统计表();
                        modeAdd.NO = Convert.ToInt32(nos[intIndex]);
                        modeAdd.单位 = int.Parse(liaoyangqkUnion[intIndex]);
                        modeAdd.姓名 = liaoyangqkVipName[intIndex].ToString();
                        modeAdd.年份 = liaoyangqkYear;
                        modeAdd.参加工作时间 = Convert.ToString(liaoyangqkworkbegintime[intIndex]);
                        modeAdd.享受标准 = Convert.ToString(liaoyangqkenjoystandard[intIndex]);

                        modeAdd.疗养时间 = Convert.ToString(liaoyangqkrecuperationtime[intIndex]);


                        modeAdd.备注 = liaoyangqkremark[intIndex].ToString();
                        liaoyangqklistModel.Add(modeAdd);
                    }
                    GH.BLL.RecuperateCondation bllRecuperateCondation = new GH.BLL.RecuperateCondation();
                    bllRecuperateCondation.UpdateList(liaoyangqklistModel);
                    break;


                //疗养计划
                case "RecuperatePlan":
                    System.Collections.Generic.List<GH.Model.员工疗养计划> liaoyangjhlistModel = new List<GH.Model.员工疗养计划>();
                    string[] liaoyangjhUnion = Request["Union"].ToString().Split(',');
                    string liaoyangjhYear = Request["theYear"].ToString();
                    string[] count1 = Request["count1"].ToString().Split(',');
                    string[] count2 = Request["count2"].ToString().Split(',');
                    string[] count3 = Request["count3"].ToString().Split(',');
                    string[] count4 = Request["count4"].ToString().Split(',');
                    string[] count5 = Request["count5"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < count1.Length - 1; intIndex++)
                    {
                        GH.Model.员工疗养计划 modeAdd = new GH.Model.员工疗养计划();
                        modeAdd.单位 = Convert.ToInt32(liaoyangjhUnion[intIndex]);
                        modeAdd.年度1 = Convert.ToString(liaoyangjhYear);
                        try
                        {

                            modeAdd.计划人数1 = Convert.ToInt32(count1[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.计划人数1 = null;
                        }
                        try
                        {

                            modeAdd.计划人数2 = Convert.ToInt32(count2[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.计划人数2 = null;
                        }
                        try
                        {

                            modeAdd.计划人数3 = Convert.ToInt32(count3[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.计划人数3 = null;
                        }
                        try
                        {

                            modeAdd.计划人数4 = Convert.ToInt32(count4[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.计划人数4 = null;
                        }
                        try
                        {

                            modeAdd.计划人数5 = Convert.ToInt32(count5[intIndex]);
                        }
                        catch (Exception)
                        {

                            modeAdd.计划人数5 = null;
                        }
                        liaoyangjhlistModel.Add(modeAdd);
                    }
                    GH.BLL.RecuperatePlan bllRecuperatePlan = new GH.BLL.RecuperatePlan();
                    bllRecuperatePlan.UpdateList(liaoyangjhlistModel);
                    break;
                //专职工会干部统计
                case "LeaderSummrise":

                    System.Collections.Generic.List<GH.Model.专职工会干部统计表> zzghListModel = new List<GH.Model.专职工会干部统计表>();

                    string[] UnionArry = Request["Union"].ToString().Split(',');//单位
                    string[] Item2 = Request["Item2"].ToString().Split(',');//姓名
                    string[] Item3 = Request["Item3"].ToString().Split(',');//工作岗位及职位
                    string[] Item4 = Request["Item4"].ToString().Split(',');//性别
                    string[] Item5 = Request["Item5"].ToString().Split(',');//出生年月
                    string[] Item6 = Request["Item6"].ToString().Split(',');//籍贯
                    string[] Item7 = Request["Item7"].ToString().Split(',');//民族
                    string[] Item8 = Request["Item8"].ToString().Split(',');//参加工作时间
                    string[] Item9 = Request["Item9"].ToString().Split(',');//政治面貌
                    string[] Item10 = Request["Item10"].ToString().Split(',');//职称
                    string[] Item11 = Request["Item11"].ToString().Split(',');//文化程度
                    string[] Item12 = Request["Item12"].ToString().Split(',');//工龄
                    string[] Nos = Request["Nos"].ToString().Split(',');//ID编号
                    string theYear = Request["theYear"].ToString();
                    for (int intIndex = 0; intIndex < UnionArry.Length - 1; intIndex++)
                    {
                        GH.Model.专职工会干部统计表 modeAdd = new GH.Model.专职工会干部统计表();
                        modeAdd.单位 = Convert.ToInt32(UnionArry[intIndex]);
                        modeAdd.姓名 = Convert.ToString(Item2[intIndex]);
                        modeAdd.工作岗位及职务 = Convert.ToString(Item3[intIndex]);
                        modeAdd.性别 = Convert.ToString(Item4[intIndex]);
                        modeAdd.出生年月 = Convert.ToDateTime(Item5[intIndex]);
                        modeAdd.籍贯 = Convert.ToString(Item6[intIndex]);
                        modeAdd.民族 = Convert.ToString(Item7[intIndex]);
                        modeAdd.参加工作时间 = Convert.ToDateTime(Item8[intIndex]);
                        modeAdd.政治面貌 = Convert.ToString(Item9[intIndex]);
                        modeAdd.技术职称 = Convert.ToString(Item10[intIndex]);
                        modeAdd.文化程度 = Convert.ToString(Item11[intIndex]);
                        modeAdd.工会工作年数 = Convert.ToInt32(Item12[intIndex]);
                        modeAdd.No = Convert.ToInt32(Nos[intIndex]);
                        modeAdd.年份 = theYear;
                        zzghListModel.Add(modeAdd);
                    }
                    GH.BLL.LeaderSummrise bllLeaderSummrise = new GH.BLL.LeaderSummrise();
                    bllLeaderSummrise.UpdateList(zzghListModel);
                    break;
                //工会建家
                case "UnionBuiltHome":
                    System.Collections.Generic.List<GH.Model.工会建家统计表> listUnionBuiltHomeModel = new List<GH.Model.工会建家统计表>();
                    //单位CD
                    string[] strUnion1Array = Request["Union"].ToString().Split(',');
                    //职工之家名称  
                    string[] strItem2Array = Request["Item2"].ToString().Split(',');
                    //工会主席
                    string[] strItem3Array = Request["Item3"].ToString().Split(',');
                    //现有等级  现有等级CD
                    string[] strItem4Array = Request["Item4"].ToString().Split(',');
                    //申报等级  申报等级CD
                    string[] strItem5Array = Request["Item5"].ToString().Split(',');
                    //会员人数
                    string[] strItem6Array = Request["Item6"].ToString().Split(',');
                    //建成时间
                    string[] strItem7Array = Request["Item7"].ToString().Split(',');
                    //备注
                    string[] strRemar1kArray = Request["Remark"].ToString().Split(',');
                    string[] strNo1 = Request["No"].ToString().Split(',');
                    string strCurrentYear = Request["CurrentYear"].ToString();


                    for (int intIndex = 0; intIndex < strUnion1Array.Length - 1; intIndex++)
                    {
                        GH.Model.工会建家统计表 modeAdd = new GH.Model.工会建家统计表();
                        modeAdd.No = int.Parse(strNo1[intIndex].ToString());
                        modeAdd.年份 = strCurrentYear;
                        modeAdd.单位 = int.Parse(strUnion1Array[intIndex].ToString());
                        modeAdd.职工之家名称 = strItem2Array[intIndex].ToString();
                        modeAdd.工会主席 = strItem3Array[intIndex].ToString();
                        modeAdd.现有等级 = strItem4Array[intIndex].ToString();
                        modeAdd.申报等级 = strItem5Array[intIndex].ToString();
                        modeAdd.会员人数 = int.Parse(strItem6Array[intIndex].ToString());
                        if (strItem7Array[intIndex].ToString() == "")
                        {
                            modeAdd.建成时间 = null;
                        }
                        else
                        {
                            modeAdd.建成时间 = DateTime.Parse(strItem7Array[intIndex].ToString());
                        }
                        modeAdd.备注 = strRemar1kArray[intIndex].ToString();
                        listUnionBuiltHomeModel.Add(modeAdd);
                    }
                    GH.BLL.UnionBuiltHome bllUnionBuiltHome = new GH.BLL.UnionBuiltHome();
                    bllUnionBuiltHome.UpdateUnionBuiltHomeList(listUnionBuiltHomeModel, int.Parse(this.Session["UnionSelect"].ToString()), this.Session["SelectCurrentYear"].ToString());
                    break;
                //取得选择日期和选择单位
                case "SelectCurrentYear":
                    this.Session["SelectCurrentYear"] = Request["Id"].ToString().Substring(0, 4);
                    break;
                //法律援助
                case "LegalAid":
                    System.Collections.Generic.List<GH.Model.工会年度法律援助统计表> listLegalAidModel = new List<GH.Model.工会年度法律援助统计表>();

                    string[] a1 = Request["a1"].ToString().Split(',');
                    string[] a2 = Request["a2"].ToString().Split(',');
                    string[] a3 = Request["a3"].ToString().Split(',');
                    string[] a4 = Request["a4"].ToString().Split(',');
                    string[] a5 = Request["a5"].ToString().Split(',');
                    string[] a6 = Request["a6"].ToString().Split(',');
                    string[] a7 = Request["a7"].ToString().Split(',');
                    string[] a8 = Request["a8"].ToString().Split(',');
                    string[] a9 = Request["a9"].ToString().Split(',');
                    string[] a10 = Request["a10"].ToString().Split(',');
                    string[] a11 = Request["a11"].ToString().Split(',');
                    string[] a12 = Request["a12"].ToString().Split(',');
                    string[] a13 = Request["a13"].ToString().Split(',');
                    string[] a14 = Request["a14"].ToString().Split(',');

                    for (int intIndex = 1; intIndex < a1.Length - 1; intIndex++)
                    {
                        GH.Model.工会年度法律援助统计表 modeAdd = new GH.Model.工会年度法律援助统计表();


                        modeAdd.厂级是否建立1 = a1[intIndex].ToString();
                        modeAdd.该委员会成员人数1 = int.Parse(a2[intIndex].ToString());
                        modeAdd.调解员培训人员 = int.Parse(a3[intIndex].ToString());
                        modeAdd.厂级是否建立2 = a4[intIndex].ToString();
                        modeAdd.该委员会成员人数2 = int.Parse(a5[intIndex].ToString());
                        modeAdd.监督员培训人数 = int.Parse(a6[intIndex].ToString());
                        modeAdd.厂级是否建立3 = a7[intIndex].ToString();
                        modeAdd.该委员会成员人数3 = int.Parse(a8[intIndex].ToString());
                        modeAdd.劳动争议件数 = int.Parse(a9[intIndex].ToString());
                        modeAdd.劳动争议职工人数 = int.Parse(a10[intIndex].ToString());
                        modeAdd.调节劳动争议件数 = int.Parse(a11[intIndex].ToString());
                        modeAdd.法律咨询人次 = int.Parse(a12[intIndex].ToString());
                        modeAdd.诉讼案件数 = int.Parse(a13[intIndex].ToString());
                        modeAdd.非诉讼案件数 = int.Parse(a14[intIndex].ToString());
                        listLegalAidModel.Add(modeAdd);
                    }
                    GH.BLL.LegalAid bllLegalAid = new GH.BLL.LegalAid();
                    bllLegalAid.UpdateList(listLegalAidModel, int.Parse(this.Session["UnionSelect"].ToString()), Request["CurrentYear"].ToString());
                    break;
                //DemocraticManagement
                case "DemocraticManagement":
                    System.Collections.Generic.List<GH.Model.厂务公开民主管理统计表> listDemocraticManagement = new List<GH.Model.厂务公开民主管理统计表>();

                    string[] b1 = Request["a1"].ToString().Split(',');
                    string[] b2 = Request["a2"].ToString().Split(',');
                    string[] b3 = Request["a3"].ToString().Split(',');
                    string[] b4 = Request["a4"].ToString().Split(',');
                    string[] b5 = Request["a5"].ToString().Split(',');
                    string[] b6 = Request["a6"].ToString().Split(',');
                    string[] b7 = Request["a7"].ToString().Split(',');
                    string[] b8 = Request["a8"].ToString().Split(',');
                    string[] b9 = Request["a9"].ToString().Split(',');
                    string[] b10 = Request["a10"].ToString().Split(',');
                    string[] b11 = Request["a11"].ToString().Split(',');
                    string[] b12 = Request["a12"].ToString().Split(',');
                    string[] b13 = Request["a13"].ToString().Split(',');
                    string[] b14 = Request["a14"].ToString().Split(',');
                    string[] b15 = Request["a15"].ToString().Split(',');
                    string[] b16 = Request["a16"].ToString().Split(',');
                    string[] b17 = Request["a17"].ToString().Split(',');
                    string[] b18 = Request["a18"].ToString().Split(',');
                    string[] b19 = Request["a19"].ToString().Split(',');
                    string[] b20 = Request["a20"].ToString().Split(',');
                    string[] b21 = Request["a21"].ToString().Split(',');
                    string[] b22 = Request["a22"].ToString().Split(',');
                    string[] b23 = Request["a23"].ToString().Split(',');
                    string[] b24 = Request["a24"].ToString().Split(',');
                    string[] b25 = Request["a25"].ToString().Split(',');
                    string[] b26 = Request["a26"].ToString().Split(',');
                    string[] b27 = Request["a27"].ToString().Split(',');
                    string[] b28 = Request["a28"].ToString().Split(',');
                    string[] b29 = Request["a29"].ToString().Split(',');
                    string[] b30 = Request["a30"].ToString().Split(',');
                    string[] b31 = Request["a31"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < b1.Length - 1; intIndex++)
                    {
                        GH.Model.厂务公开民主管理统计表 modeAdd = new GH.Model.厂务公开民主管理统计表();
                        modeAdd.召开次数 = strToInt(b1[intIndex].ToString());
                        modeAdd.审议企业重大事项 = strToInt(b2[intIndex].ToString());
                        modeAdd.征集提案 = strToInt(b3[intIndex].ToString());
                        modeAdd.得到落实或回复1 = strToInt(b4[intIndex].ToString());
                        modeAdd.意见提议 = strToInt(b5[intIndex].ToString());
                        modeAdd.得到落实或回复2 = strToInt(b6[intIndex].ToString());
                        modeAdd.举办职业代表培训 = strToInt(b7[intIndex].ToString());
                        modeAdd.审议议案 = strToInt(b8[intIndex].ToString());
                        modeAdd.召开职代会联席会议 = strToInt(b9[intIndex].ToString());
                        modeAdd.培训职工代表 = strToInt(b10[intIndex].ToString());
                        modeAdd.评议厂级干部次 = strToInt(b11[intIndex].ToString());
                        modeAdd.评议厂级干部人 = strToInt(b12[intIndex].ToString());
                        modeAdd.评议中层领导干部次 = strToInt(b13[intIndex].ToString());
                        modeAdd.评议中层领导干部人 = strToInt(b14[intIndex].ToString());
                        modeAdd.公开的事项 = strToInt(b15[intIndex].ToString());
                        modeAdd.公开的满意度 = decimal.Parse(b16[intIndex].ToString());
                        modeAdd.事物二级单位数 = strToInt(b17[intIndex].ToString());
                        modeAdd.班组数 = strToInt(b18[intIndex].ToString());
                        modeAdd.开展巡视检查次数 = strToInt(b19[intIndex].ToString());
                        modeAdd.参与讯巡视检查人数 = strToInt(b20[intIndex].ToString());
                        modeAdd.被检察单位或部门数 = strToInt(b21[intIndex].ToString());
                        modeAdd.提出整改意见数 = strToInt(b22[intIndex].ToString());
                        modeAdd.整改意见落实数 = strToInt(b23[intIndex].ToString());
                        modeAdd.职工代表满意度 = decimal.Parse(b24[intIndex].ToString());
                        modeAdd.合同是否按揭续签 = b25[intIndex].ToString();
                        modeAdd.是否签订女职工合同 = b26[intIndex].ToString();
                        modeAdd.集体合同检查次数 = strToInt(b27[intIndex].ToString());
                        modeAdd.是否签订安全生产合同 = b28[intIndex].ToString();
                        modeAdd.是否开展创建活动 = b29[intIndex].ToString();
                        modeAdd.创建活动二级单位数 = strToInt(b30[intIndex].ToString());
                        modeAdd.是否获得企业称号 = b31[intIndex].ToString();
                        listDemocraticManagement.Add(modeAdd);
                    }
                    GH.BLL.DemocraticManagement bllDemocraticManagement = new GH.BLL.DemocraticManagement();
                    bllDemocraticManagement.UpdateList(listDemocraticManagement, strToInt(this.Session["UnionSelect"].ToString()), Request["CurrentYear"].ToString());
                    break;
                //劳动模范情况统计表
                case "ModelWorker":
                    System.Collections.Generic.List<GH.Model.劳动模范> listModel1 = new List<GH.Model.劳动模范>();
                    System.Collections.Generic.List<GH.Model.先进集体统计表> listModel2 = new List<GH.Model.先进集体统计表>();
                    string[] c1 = Request["a1"].ToString().Split(',');
                    string[] c2 = Request["a2"].ToString().Split(',');
                    string[] c3 = Request["a3"].ToString().Split(',');
                    string[] c4 = Request["a4"].ToString().Split(',');
                    string[] c5 = Request["a5"].ToString().Split(',');
                    string[] c6 = Request["a6"].ToString().Split(',');
                    string[] c7 = Request["a7"].ToString().Split(',');
                    string[] c8 = Request["a8"].ToString().Split(',');


                    for (int intIndex = 0; intIndex < c1.Length - 1; intIndex++)
                    {
                        GH.Model.劳动模范 modeAdd = new GH.Model.劳动模范();

                        modeAdd.姓名 = c1[intIndex].ToString();
                        modeAdd.个人奖项 = c2[intIndex].ToString();
                        modeAdd.性别 = c3[intIndex].ToString();
                        modeAdd.出生年月 = DateTime.Parse(c4[intIndex].ToString());
                        modeAdd.获奖时间 = DateTime.Parse(c5[intIndex].ToString());
                        modeAdd.文化程度 = c6[intIndex].ToString();
                        modeAdd.政治面貌 = c7[intIndex].ToString();
                        modeAdd.岗位及职务 = c8[intIndex].ToString();

                        listModel1.Add(modeAdd);
                    }

                    string[] d1 = Request["b1"].ToString().Split(',');
                    string[] d2 = Request["b2"].ToString().Split(',');
                    string[] d3 = Request["b3"].ToString().Split(',');
                    string[] d4 = Request["b4"].ToString().Split(',');
                    for (int intIndex = 0; intIndex < d1.Length - 1; intIndex++)
                    {
                        GH.Model.先进集体统计表 modeAdd = new GH.Model.先进集体统计表();
                        modeAdd.单位名称 = d1[intIndex].ToString();
                        modeAdd.集体奖项 = d2[intIndex].ToString();
                        modeAdd.j集体获奖时间 = DateTime.Parse(d3[intIndex].ToString());
                        modeAdd.备注 = d4[intIndex].ToString(); ;
                        listModel2.Add(modeAdd);
                    }
                    GH.BLL.ModelWorker bllModelWorker = new GH.BLL.ModelWorker();
                    bllModelWorker.UpdateList(listModel1, listModel2, 000, Request["CurrentYear"].ToString());
                    break;

                //聘用各类劳务人员入会率统计表 
                case "EmployMemberShipRate":
                    string[] EmployMemberShipRateUnionArry = Request["Union"].ToString().Split(',');//单位
                    string theEmployMemberShipRateYear = Request["theYear"].ToString();
                    System.Collections.Generic.List<GH.Model.聘用各类劳务人员入会率统计表> listEmployMemberShipRate = new List<GH.Model.聘用各类劳务人员入会率统计表>();

                    string[] EmployMemberShipRatef1 = Request["Item1"].ToString().Split(',');
                    string[] EmployMemberShipRatef2 = Request["Item2"].ToString().Split(',');
                    string[] EmployMemberShipRatef3 = Request["Item3"].ToString().Split(',');
                    string[] EmployMemberShipRatef4 = Request["Item4"].ToString().Split(',');
                    string[] EmployMemberShipRatef5 = Request["Item5"].ToString().Split(',');
                    string[] EmployMemberShipRatef6 = Request["Item6"].ToString().Split(',');
                    string[] EmployMemberShipRatef7 = Request["Item7"].ToString().Split(',');
                    string[] EmployMemberShipRatef8 = Request["Item8"].ToString().Split(',');
                    string[] EmployMemberShipRatef9 = Request["Item9"].ToString().Split(',');
                    string[] EmployMemberShipRatef10 = Request["Item10"].ToString().Split(',');
                    string[] EmployMemberShipRatef11 = Request["Item11"].ToString().Split(',');
                    string[] EmployMemberShipRatef12 = Request["Item12"].ToString().Split(',');
                    string[] EmployMemberShipRatef13 = Request["Item13"].ToString().Split(',');
                    string[] EmployMemberShipRatef14 = Request["Item14"].ToString().Split(',');
                    string[] EmployMemberShipRatef15 = Request["Item15"].ToString().Split(',');



                    for (int intIndex = 0; intIndex < EmployMemberShipRatef1.Length - 1; intIndex++)
                    {
                        GH.Model.聘用各类劳务人员入会率统计表 modeAdd = new GH.Model.聘用各类劳务人员入会率统计表();
                        modeAdd.聘用人员总数 = int.Parse(EmployMemberShipRatef1[intIndex].ToString());
                        modeAdd.单位 = int.Parse(EmployMemberShipRateUnionArry[intIndex]);
                        modeAdd.年份 = theEmployMemberShipRateYear;
                        modeAdd.聘用各类会员总数 = int.Parse(EmployMemberShipRatef2[intIndex].ToString());
                        modeAdd.同类员工入会率1 = decimal.Parse(EmployMemberShipRatef3[intIndex].ToString().Replace("%", ""));
                        modeAdd.电业局管辖电工数 = int.Parse(EmployMemberShipRatef4[intIndex].ToString());
                        modeAdd.电业局管辖电工会员数 = int.Parse(EmployMemberShipRatef5[intIndex].ToString());
                        modeAdd.同类员工入会率2 = decimal.Parse(EmployMemberShipRatef6[intIndex].ToString().Replace("%", ""));
                        modeAdd.省公司控股代电工数 = int.Parse(EmployMemberShipRatef7[intIndex].ToString());
                        modeAdd.省公司控股会员数 = int.Parse(EmployMemberShipRatef8[intIndex].ToString());
                        modeAdd.同类员工入会率3 = decimal.Parse(EmployMemberShipRatef9[intIndex].ToString().Replace("%", ""));
                        modeAdd.本单位聘用人员数 = int.Parse(EmployMemberShipRatef10[intIndex].ToString());
                        modeAdd.本单位聘用人员会员数 = int.Parse(EmployMemberShipRatef11[intIndex].ToString());
                        modeAdd.同类员工入会率4 = decimal.Parse(EmployMemberShipRatef12[intIndex].ToString().Replace("%", ""));
                        modeAdd.各单位聘用人员数 = int.Parse(EmployMemberShipRatef13[intIndex].ToString());
                        modeAdd.各单位聘用会员数 = int.Parse(EmployMemberShipRatef14[intIndex].ToString());
                        modeAdd.同类员工入会率5 = decimal.Parse(EmployMemberShipRatef15[intIndex].ToString().Replace("%", ""));
                        listEmployMemberShipRate.Add(modeAdd);
                    }
                    GH.BLL.EmployMemberShipRate bllEmployMemberShipRate = new GH.BLL.EmployMemberShipRate();
                    bllEmployMemberShipRate.UpdateList(listEmployMemberShipRate);
                    break;
                //各类员工入会率统计 
                case "MemberShipRate":

                    string[] MemberShipRateUnionArry = Request["Union"].ToString().Split(',');//单位
                    string MemberShipRateYear = Request["theYear"].ToString();
                    System.Collections.Generic.List<GH.Model.各类员工入会率统计表> listMemberShipRate = new List<GH.Model.各类员工入会率统计表>();


                    string[] f1 = Request["Item1"].ToString().Split(',');
                    string[] f2 = Request["Item2"].ToString().Split(',');
                    string[] f3 = Request["Item3"].ToString().Split(',');
                    string[] f4 = Request["Item4"].ToString().Split(',');
                    string[] f5 = Request["Item5"].ToString().Split(',');
                    string[] f6 = Request["Item6"].ToString().Split(',');
                    string[] f7 = Request["Item7"].ToString().Split(',');
                    string[] f8 = Request["Item8"].ToString().Split(',');
                    string[] f9 = Request["Item9"].ToString().Split(',');
                    string[] f10 = Request["Item10"].ToString().Split(',');
                    string[] f11 = Request["Item11"].ToString().Split(',');
                    string[] f12 = Request["Item12"].ToString().Split(',');
                    string[] f13 = Request["Item13"].ToString().Split(',');
                    string[] f14 = Request["Item14"].ToString().Split(',');
                    string[] f15 = Request["Item15"].ToString().Split(',');



                    for (int intIndex = 0; intIndex < f1.Length - 1; intIndex++)
                    {
                        GH.Model.各类员工入会率统计表 modeAdd = new GH.Model.各类员工入会率统计表();
                        modeAdd.单位 = int.Parse(MemberShipRateUnionArry[intIndex].ToString());
                        modeAdd.年份 = MemberShipRateYear;
                        modeAdd.各类员工合计 = strToInt(f1[intIndex].ToString());
                        modeAdd.各类员工会员合计 = strToInt(f2[intIndex].ToString());
                        modeAdd.各类员工入会率 = decimal.Parse(f3[intIndex].ToString().Replace("%", ""));
                        modeAdd.省公司所有制员工数 = strToInt(f4[intIndex].ToString());
                        modeAdd.省公司所有制会员数 = strToInt(f5[intIndex].ToString());
                        modeAdd.同类员工入会率1 = decimal.Parse(f6[intIndex].ToString().Replace("%", ""));
                        modeAdd.省公司控股员工数 = strToInt(f7[intIndex].ToString());
                        modeAdd.省公司控股会员数 = strToInt(f8[intIndex].ToString());
                        modeAdd.同类员工入会率2 = decimal.Parse(f9[intIndex].ToString().Replace("%", ""));
                        modeAdd.多经企业员工数 = strToInt(f10[intIndex].ToString());
                        modeAdd.多经企业员工会员数 = strToInt(f11[intIndex].ToString());
                        modeAdd.同类员工入会率3 = decimal.Parse(f12[intIndex].ToString().Replace("%", ""));
                        modeAdd.聘用人员总数 = strToInt(f13[intIndex].ToString());
                        modeAdd.聘用会员总数1 = strToInt(f14[intIndex].ToString());
                        modeAdd.同类员工入会率4 = decimal.Parse(f15[intIndex].ToString().Replace("%", ""));
                        listMemberShipRate.Add(modeAdd);
                    }
                    GH.BLL.MemberShipRate bllMemberShipRate = new GH.BLL.MemberShipRate();
                    bllMemberShipRate.UpdateList(listMemberShipRate);
                    break;
                case "LeaderTrain":
                    string strCurrent = Request["theYear"].ToString();
                    System.Collections.Generic.List<GH.Model.工会组织干部培训统计表> listLeaderTrain = new List<GH.Model.工会组织干部培训统计表>();

                    string[] g0 = Request["Item0"].ToString().Split(',');
                    string[] g1 = Request["Item1"].ToString().Split(',');
                    string[] g2 = Request["Item2"].ToString().Split(',');
                    string[] g3 = Request["Item3"].ToString().Split(',');
                    string[] g4 = Request["Item4"].ToString().Split(',');
                    string[] g5 = Request["Item5"].ToString().Split(',');
                    string[] g6 = Request["Item6"].ToString().Split(',');
                    string[] g7 = Request["Item7"].ToString().Split(',');
                    string[] g8 = Request["Item8"].ToString().Split(',');
                    string[] g9 = Request["Item9"].ToString().Split(',');
                    string[] g10 = Request["Item10"].ToString().Split(',');
                    string[] g11 = Request["Item11"].ToString().Split(',');
                    string[] g12 = Request["Item12"].ToString().Split(',');
                    string[] g13 = Request["Item13"].ToString().Split(',');
                    string[] g14 = Request["Item14"].ToString().Split(',');
                    string[] g15 = Request["Item15"].ToString().Split(',');



                    for (int intIndex = 0; intIndex < g0.Length - 1; intIndex++)
                    {
                        GH.Model.工会组织干部培训统计表 modeAdd = new GH.Model.工会组织干部培训统计表();
                        modeAdd.单位 = int.Parse(g0[intIndex].ToString());
                        modeAdd.年份 = strCurrent;
                        modeAdd.所属基层分工会数 = strToInt(g1[intIndex].ToString());
                        modeAdd.省公司所属企业分工会数 = strToInt(g2[intIndex].ToString());
                        modeAdd.省公司控股分工会数 = strToInt(g3[intIndex].ToString().Replace("%", ""));
                        modeAdd.分工会数 = strToInt(g4[intIndex].ToString());
                        modeAdd.劳务人员分工会数 = strToInt(g5[intIndex].ToString());
                        modeAdd.所属基层工会小组数 = strToInt(g6[intIndex].ToString().Replace("%", ""));
                        modeAdd.省公司所属工会小组数 = strToInt(g7[intIndex].ToString());
                        modeAdd.省公司控股工会小组数 = strToInt(g8[intIndex].ToString());
                        modeAdd.工会小组数 = strToInt(g9[intIndex].ToString().Replace("%", ""));
                        modeAdd.劳务人员工会小组数 = strToInt(g10[intIndex].ToString());
                        modeAdd.专职工会干部数 = strToInt(g11[intIndex].ToString());
                        modeAdd.培训班次 = strToInt(g12[intIndex].ToString().Replace("%", ""));
                        modeAdd.培训人次 = strToInt(g13[intIndex].ToString());
                        modeAdd.年度培训人数 = strToInt(g14[intIndex].ToString());
                        modeAdd.年度培训率 = strToDecimal(g15[intIndex].ToString().Replace("%", ""));
                        listLeaderTrain.Add(modeAdd);
                    }
                    GH.BLL.LeaderTrain blllistLeaderTrain = new GH.BLL.LeaderTrain();
                    blllistLeaderTrain.UpdateList(listLeaderTrain);

                    break;

            }
            Response.Write("OK");
        }
        catch
        {
            Response.Write("NG");
        }
        Response.End();
    }

    public int strToInt(string strValue)
    {
        if (strValue.Trim() == "")
        {
            return 0;
        }
        else
        {
            return int.Parse(strValue);
        }
    }

    public decimal strToDecimal(string strValue)
    {
        if (strValue.Trim() == "")
        {
            return 0;
        }
        else
        {
            return decimal.Parse(strValue);
        }
    }
}
